package com.vim.modules.mall.service.impl;

import com.github.pagehelper.PageInfo;
import com.vim.common.utils.AssertUtils;
import com.vim.modules.mall.model.base.CommonPage;
import com.vim.modules.mall.model.base.MallResponseEntity;
import com.vim.modules.mall.model.base.Page;
import com.vim.modules.mall.model.base.PageConvertUtils;
import com.vim.modules.mall.model.mallOrder.MallOrderReturnApply;
import com.vim.modules.mall.service.MallOrderReturnApplyService;
import com.vim.modules.mall.service.remote.RemoteMallOrderReturnApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @作者 Administrator
 * @时间 2020-10-06 14:59
 * @版本 1.0
 */
@Service
public class MallOrderReturnApplyServiceImpl implements MallOrderReturnApplyService {

    @Autowired
    private RemoteMallOrderReturnApplyService remoteMallOrderReturnApplyService;

    /**
     * 获取订单售后列表
     */
    @Override
    public List<MallOrderReturnApply> orderReturnApplyList(Long orderId) {
        MallResponseEntity<List<MallOrderReturnApply>> result = remoteMallOrderReturnApplyService.orderReturnApplyList(orderId);
        AssertUtils.assertAjaxOK(result);
        return result.getData();
    }

    /**
     * 获取订单售后列表
     */
    @Override
    public PageInfo<MallOrderReturnApply> orderReturnApplyPageList(Page page) {
        MallResponseEntity<CommonPage<MallOrderReturnApply>> result = remoteMallOrderReturnApplyService.orderReturnApplyPageList(page.getPageNo(), page.getPageSize());
        AssertUtils.assertAjaxOK(result);
        return PageConvertUtils.convert(result.getData());
    }

    /**
     * 获取订单售后详情
     * @param applyId 售后id
     */
    @Override
    public MallOrderReturnApply orderReturnApplyInfo(Long applyId) {
        MallResponseEntity<MallOrderReturnApply> result = remoteMallOrderReturnApplyService.orderReturnApplyInfo(applyId);
        AssertUtils.assertAjaxOK(result);
        return result.getData();
    }
}
